#ifndef __LINKLIST_H_
#define __LINKLIST_H_

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#define ElementType int

struct Node
{
    ElementType value;
    struct Node *next;
};
typedef struct Node node;

struct LinkList
{
    node* head;
    int len;
};
typedef struct LinkList Llist;

void InitLinkList(Llist *list);
void TravelLinkList(Llist *list);
bool InsertLinkTail(Llist *list, ElementType element);
bool InsertHead(Llist *list, ElementType element);
bool InsertByIndex(Llist *list, int index, ElementType element);
bool RemoveByIndex(Llist *list, int index);
bool RemoveByElement(Llist *list, ElementType element);
bool UpdateByIndex(Llist *list, int index, ElementType element);
bool UpdateByElement(Llist *list, ElementType oldValue, ElementType newValue);
ElementType* FindElementByIndex(Llist *list, int index);
int* FindElementByValue(Llist *list, ElementType element);
bool IsHaveElement(Llist *list, ElementType element);
bool IsEmpty(Llist *list);
void BubbleSort(Llist *list);
Llist GetInsection(Llist *list1, Llist *list2);
Llist GetUnionSet(Llist *list1, Llist *list2);
Llist Merge(Llist *list1, Llist *list2);
void Reserve(Llist *list);
node* ReserveRecursive(node *n);
void FreeLinkList(Llist *list);

#endif